<template>
	<view class="warp">
		<rich-text :nodes="data.content"></rich-text>
	</view>
</template>

<script>
	const db = uniCloud.database();

	export default {
		data() {
			return {
				id: '',
				data: {},
				title:''
			}
		},
		onLoad(op) {
			// console.log("op", op)
			if (op.id) {
				this.id = op.id
				this.loadData()
			}
			if(op.title){
				this.title = op.title
			}
		},
		onReady() {
			if(this.title){
				uni.setNavigationBarTitle({
					title: this.title
				});
			}
		},
		methods: {
			loadData() {
				db.collection("opendb-news-articles").doc(this.id).field("content").get().then(res => {
					// console.log(res)
					this.data = Object.assign({}, res.result.data[0])
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.warp {
		padding: 10px;
	}
</style>